var x86 = "c:\\program files\\Microsoft Visual Studio 9.0\\Common7\\IDE\\devenv.exe";
var x64 = "c:\\program files (x86)\\Microsoft Visual Studio 9.0\\Common7\\IDE\\devenv.exe";
var shell = new ActiveXObject("WScript.Shell");
var fso = new ActiveXObject("Scripting.FileSystemObject");

if (fso.FileExists(x86))
{
    shell.Exec(x86 + " /InstallVSTemplates");
}
else if (fso.FileExists(x64))
{
    shell.Exec(x64 + " /InstallVSTemplates");
}
